home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / gnulib / sipp / srgp / src / srgp_out.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-01  |  32.5 KB  |  1,286 lines

  1. #include "HEADERS.h"
  2. #include "srgplocal.h"
  3.  
  4. #ifndef GRX
  5. #define TURN_OFF_RUBBER_ECHO_IF_ANY \
  6.    SRGP__disableLocatorRubberEcho()
  7.  
  8. #define TURN_ON_RUBBER_ECHO_IF_ANY \
  9.    SRGP__enableLocatorRubberEcho()
  10. #else
  11. #  define TURN_OFF_RUBBER_ECHO_IF_ANY
  12. #  define TURN_ON_RUBBER_ECHO_IF_ANY
  13. #endif
  14.  
  15.  
  16. #ifdef THINK_C
  17. static Rect r;
  18.  
  19. #define DONT_DRAW  -1   /* must match srgp_attrib.c */
  20.  
  21.  
  22. #define SET_PORT_FOR_FRAME_GENRE() \
  23. if (srgp__curActiveCanvasSpec.transfermode_frame == DONT_DRAW) return; else { \
  24.    PenMode (srgp__curActiveCanvasSpec.transfermode_frame); \
  25.    PenPat (srgp__curActiveCanvasSpec.pat_frame); }
  26.  
  27. #define SET_PORT_FOR_FILL_GENRE() \
  28. if (srgp__curActiveCanvasSpec.transfermode_fill == DONT_DRAW) return; else { \
  29.    PenMode (srgp__curActiveCanvasSpec.transfermode_fill); \
  30.    PenPat (srgp__curActiveCanvasSpec.pat_fill); }
  31.  
  32. #endif
  33.  
  34.  
  35.  
  36. /** Functions creating geometric data
  37. **/
  38.  
  39. point SRGP_defPoint (int x, int y)
  40. {
  41.    point pt;
  42.  
  43.    pt.x = x;
  44.    pt.y = y;
  45.    return pt;
  46. }
  47.  
  48. rectangle SRGP_defRectangle (int left_x, int bottom_y, int right_x, int top_y)
  49. {
  50.    rectangle rect;
  51.  
  52.    rect.bottom_left.x = left_x;
  53.    rect.bottom_left.y = bottom_y;
  54.    rect.top_right.x = right_x;
  55.    rect.top_right.y = top_y;
  56.    return rect;
  57. }
  58.  
  59.  
  60.  
  61.  
  62. /** AUDIO
  63. **/
  64.  
  65. #ifdef GRX
  66. # include <stdio.h>
  67. #endif
  68.  
  69. void
  70. SRGP_beep()
  71. {
  72. #ifdef X11
  73.    XBell (srgpx__display, 0);
  74. #endif
  75. #ifdef THINK_C
  76.    SysBeep(30);
  77. #endif
  78. #ifdef GRX
  79.    putchar('G' - 0x40);
  80.    fflush(stdout);
  81. #endif
  82. }
  83.  
  84. #ifdef GRX
  85.  
  86. typedef void (*grx2coordfunc)(int,int,long);
  87. typedef void (*grx3coordfunc)(int,int,int,long);
  88. typedef void (*grx4coordfunc)(int,int,int,int,long);
  89. typedef void (*grx5coordfunc)(int,int,int,int,int,long);
  90. typedef void (*grx6coordfunc)(int,int,int,int,int,int,long);
  91. typedef void (*grxPOLYcoordfunc)(int,int [][2],long);
  92.  
  93. #define BUILD_GRX_DRAWTABLE(numargs,funcname)                               \
  94.         static grx##numargs##coordfunc table[] = {                          \
  95.             (grx##numargs##coordfunc)Gr##funcname,                          \
  96.             (grx##numargs##coordfunc)GrCustom##funcname,                    \
  97.             (grx##numargs##coordfunc)GrPatterned##funcname                  \
  98.         }
  99. #define GRX_DRAW_FUNC   (*(table[srgp__curActiveCanvasSpec.grx_pen_style]))
  100. #define GRX_DRAW_ARG    (srgp__curActiveCanvasSpec.grx_pen_data.val)
  101.                                                                             \
  102. #define BUILD_GRX_FILLTABLE(numargs,funcname)                               \
  103.         static grx##numargs##coordfunc table[] = {                          \
  104.             (grx##numargs##coordfunc)GrFilled##funcname,                    \
  105.             (grx##numargs##coordfunc)GrPatternFilled##funcname              \
  106.         }
  107. #define GRX_FILL_FUNC   (*(table[srgp__curActiveCanvasSpec.grx_fill_style]))
  108. #define GRX_FILL_ARG    (srgp__curActiveCanvasSpec.grx_fill_data.val)
  109.  
  110. #endif
  111.  
  112.  
  113.  
  114. /** POINTS
  115. **/
  116.  
  117. void
  118. SRGP_pointCoord (int x, int y)
  119. {
  120.    DEBUG_AIDS{
  121.       SRGP_trace (SRGP_logStream, "SRGP_pointCoord: %d,%d\n", x,y);
  122.       srgp_check_system_state();
  123.       LeaveIfNonFatalErr();
  124.    }
  125.  
  126.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  127. #ifdef X11
  128.    XDrawPoint
  129.       (srgpx__display,
  130.        srgp__curActiveCanvasSpec.drawable.xid,
  131.        srgp__curActiveCanvasSpec.gc_frame,
  132.        x, FIXED(y));
  133. #endif
  134. #ifdef THINK_C
  135.    SET_PORT_FOR_FRAME_GENRE();
  136.    MoveTo(x,FIXED(y));
  137.    Line(0,0);
  138. #endif
  139. #ifdef GRX
  140.    {
  141.         static grx2coordfunc table[] = {
  142.             (grx2coordfunc)GrPlot,
  143.             (grx2coordfunc)GrPatternFilledPlot,
  144.         };
  145.  
  146.         (*(table[srgp__curActiveCanvasSpec.grx_fill_style]))(
  147.             x,FIXED(y),
  148.             srgp__curActiveCanvasSpec.grx_fill_data.val
  149.         );
  150.    }
  151. #endif
  152.    TURN_ON_RUBBER_ECHO_IF_ANY;
  153. }
  154.  
  155. void
  156. SRGP_point (point pt)
  157. {
  158.    DEBUG_AIDS{
  159.       SRGP_trace (SRGP_logStream, "SRGP_point: %d,%d\n", ExplodePt(pt));
  160.    }
  161.  
  162.    PUSH_TRACE;
  163.    SRGP_pointCoord (pt.x, pt.y);
  164.    POP_TRACE;
  165. }
  166.  
  167. void
  168. SRGP_polyPoint (int vertex_count, point *vertices)
  169. {
  170.    register int i;
  171.  
  172.    DEBUG_AIDS{
  173.       SRGP_trace (SRGP_logStream, "SRGP_polyPoint  %d 0x%x\n",
  174.                vertex_count, vertices);
  175.       srgp_check_system_state();
  176.       srgp_check_polymarker_list_size(vertex_count);
  177.       LeaveIfNonFatalErr();
  178.    }
  179.  
  180.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  181.  
  182. #ifdef X11
  183.    for (i=0; i<vertex_count; i++) {
  184.       Xformat_vertices[i].x = vertices[i].x;
  185.       Xformat_vertices[i].y = FIXED(vertices[i].y);
  186.    }
  187.    XDrawPoints
  188.       (srgpx__display,
  189.        srgp__curActiveCanvasSpec.drawable.xid,
  190.        srgp__curActiveCanvasSpec.gc_frame,
  191.        Xformat_vertices, vertex_count, CoordModeOrigin);
  192. #endif
  193.  
  194. #ifdef THINK_C
  195.    PUSH_TRACE;
  196.    for (i=0; i<vertex_count; i++)
  197.       SRGP_pointCoord (vertices[i].x, FIXED(vertices[i].y));
  198.    POP_TRACE;
  199. #endif
  200.  
  201. #ifdef GRX
  202.    {
  203.         static grx2coordfunc table[] = {
  204.             (grx2coordfunc)GrPlot,
  205.             (grx2coordfunc)GrPatternFilledPlot,
  206.         };
  207.  
  208.         for(i=0; i<vertex_count; i++) {
  209.             (*(table[srgp__curActiveCanvasSpec.grx_fill_style]))(
  210.                 vertices[i].x,FIXED(vertices[i].y),
  211.                 srgp__curActiveCanvasSpec.grx_fill_data.val
  212.             );
  213.         }
  214.    }
  215. #endif
  216.  
  217.    TURN_ON_RUBBER_ECHO_IF_ANY;
  218. }
  219.  
  220.  
  221. void
  222. SRGP_polyPointCoord (int vertex_count, int *x_coords, int *y_coords)
  223. {
  224.    register int i;
  225.  
  226.    DEBUG_AIDS{
  227.       SRGP_trace (SRGP_logStream, "SRGP_polyPointCoord  %d 0x%x,0x%x\n",
  228.                   vertex_count, x_coords, y_coords);
  229.       srgp_check_system_state();
  230.       srgp_check_polymarker_list_size(vertex_count);
  231.       LeaveIfNonFatalErr();
  232.    }
  233.  
  234.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  235.  
  236. #ifdef X11
  237.    for (i=0; i < vertex_count; i++) {
  238.       Xformat_vertices[i].x = x_coords[i];
  239.       Xformat_vertices[i].y = FIXED(y_coords[i]);
  240.    }
  241.    XDrawPoints
  242.       (srgpx__display,
  243.        srgp__curActiveCanvasSpec.drawable.xid,
  244.        srgp__curActiveCanvasSpec.gc_frame,
  245.        Xformat_vertices, vertex_count, CoordModeOrigin);
  246. #endif
  247.  
  248. #ifdef THINK_C
  249.    PUSH_TRACE;
  250.    for (i=0; i<vertex_count; i++)
  251.       SRGP_pointCoord (x_coords[i], FIXED(y_coords[i]));
  252.    POP_TRACE;
  253. #endif
  254.  
  255. #ifdef GRX
  256.    {
  257.         static grx2coordfunc table[] = {
  258.             (grx2coordfunc)GrPlot,
  259.             (grx2coordfunc)GrPatternFilledPlot,
  260.         };
  261.  
  262.         for(i=0; i<vertex_count; i++) {
  263.             (*(table[srgp__curActiveCanvasSpec.grx_fill_style]))(
  264.                 x_coords[i],FIXED(y_coords[i]),
  265.                 srgp__curActiveCanvasSpec.grx_fill_data.val
  266.             );
  267.         }
  268.    }
  269. #endif
  270.  
  271.    TURN_ON_RUBBER_ECHO_IF_ANY;
  272. }
  273.  
  274.  
  275.  
  276.  
  277. /** MARKERS
  278. **/
  279.  
  280. extern int srgp__marker_radius;  /* found in marker.c */
  281. static int linewidthtemp, saveLineWidth;
  282.  
  283. static void
  284. GetReadyToPaintMarkers (void)
  285. {
  286.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  287.    PUSH_TRACE;
  288.  
  289.    srgp__marker_radius = srgp__curActiveCanvasSpec.attributes.marker_size >> 1;
  290.  
  291. #ifdef THINK_C
  292.    SET_PORT_FOR_FRAME_GENRE();
  293. #endif
  294.  
  295.    saveLineWidth = srgp__curActiveCanvasSpec.attributes.line_width;
  296.    SRGP_setLineWidth
  297.       (((linewidthtemp=(srgp__marker_radius>>3))==0)?1:linewidthtemp);
  298. }
  299.  
  300.  
  301. static void
  302. FinishPaintingMarkers (void)
  303. {
  304.    SRGP_setLineWidth (saveLineWidth);
  305.  
  306.    POP_TRACE;
  307.    TURN_ON_RUBBER_ECHO_IF_ANY;
  308. }
  309.  
  310.  
  311.  
  312. void
  313. SRGP_markerCoord (int x, int y)
  314. {
  315.    DEBUG_AIDS{
  316.       SRGP_trace (SRGP_logStream, "SRGP_markerCoord: %d,%d\n", x,y);
  317.       srgp_check_system_state();
  318.       LeaveIfNonFatalErr();
  319.    }
  320.  
  321.    GetReadyToPaintMarkers();
  322.    switch (srgp__curActiveCanvasSpec.attributes.marker_style) {
  323.     case MARKER_CIRCLE: SRGP__drawCircleMarker (x,y); break;
  324.     case MARKER_SQUARE: SRGP__drawSquareMarker (x,y); break;
  325.     case MARKER_X: SRGP__drawXMarker (x,y); break;
  326.    }
  327.    FinishPaintingMarkers();
  328. }
  329.  
  330.  
  331. void
  332. SRGP_marker (point pt)
  333. {
  334.    DEBUG_AIDS{
  335.       SRGP_trace (SRGP_logStream, "SRGP_marker: %d,%d\n", pt.x, pt.y);
  336.       srgp_check_system_state();
  337.       LeaveIfNonFatalErr();
  338.    }
  339.  
  340.    GetReadyToPaintMarkers();
  341.    switch (srgp__curActiveCanvasSpec.attributes.marker_style) {
  342.     case MARKER_CIRCLE: SRGP__drawCircleMarker (pt.x,pt.y); break;
  343.     case MARKER_SQUARE: SRGP__drawSquareMarker (pt.x,pt.y); break;
  344.     case MARKER_X: SRGP__drawXMarker (pt.x,pt.y); break;
  345.    }
  346.    FinishPaintingMarkers();
  347. }
  348.  
  349.  
  350. void
  351. SRGP_polyMarker (int vertex_count, point *vertices)
  352. {
  353.    DEBUG_AIDS{
  354.       SRGP_trace (SRGP_logStream, "SRGP_polyMarker: %d  %lx\n",
  355.                   vertex_count, vertices);
  356.       srgp_check_polymarker_list_size(vertex_count);
  357.       srgp_check_system_state();
  358.       LeaveIfNonFatalErr();
  359.    }
  360.  
  361.    GetReadyToPaintMarkers();
  362.    while (vertex_count--) {
  363.       switch (srgp__curActiveCanvasSpec.attributes.marker_style) {
  364.        case MARKER_CIRCLE:
  365.          SRGP__drawCircleMarker (vertices->x,vertices->y); break;
  366.        case MARKER_SQUARE:
  367.          SRGP__drawSquareMarker (vertices->x,vertices->y); break;
  368.        case MARKER_X:
  369.          SRGP__drawXMarker (vertices->x,vertices->y); break;
  370.       }
  371.       vertices++;
  372.    }
  373.    FinishPaintingMarkers();
  374. }
  375.  
  376.  
  377. void
  378. SRGP_polyMarkerCoord (int vertex_count, int *xlist, int *ylist)
  379. {
  380.    DEBUG_AIDS{
  381.       SRGP_trace (SRGP_logStream, "SRGP_polyMarkerCoord: %d  %lx %lx\n",
  382.                   vertex_count, xlist, ylist);
  383.       srgp_check_polymarker_list_size(vertex_count);
  384.       srgp_check_system_state();
  385.       LeaveIfNonFatalErr();
  386.    }
  387.  
  388.    GetReadyToPaintMarkers();
  389.    while (vertex_count--) {
  390.       switch (srgp__curActiveCanvasSpec.attributes.marker_style) {
  391.        case MARKER_CIRCLE: SRGP__drawCircleMarker (*xlist, *ylist); break;
  392.        case MARKER_SQUARE: SRGP__drawSquareMarker (*xlist, *ylist); break;
  393.        case MARKER_X: SRGP__drawXMarker (*xlist, *ylist); break;
  394.       }
  395.       xlist++; ylist++;
  396.    }
  397.    FinishPaintingMarkers();
  398. }
  399.  
  400.  
  401.  
  402. /** LINES
  403. X11 handles dashes, etc. itself.
  404. Macintosh:  we must simulate all line styles other than continuous.
  405. **/
  406.  
  407.  
  408. #ifdef THINK_C
  409. typedef void (*voidfuncptr)();
  410. static int xpresent, ypresent;
  411. static boolean off;
  412.  
  413.  
  414. static void plotdash (int x, int y, int s)
  415. {
  416.    int j = s % 10;
  417.    off = (j < 5);
  418.    if ( ! off) {
  419.       MoveTo (x, y);
  420.       LineTo (x, y);
  421.    }
  422. }
  423.  
  424.  
  425. static void plotdot (int x, int y, int s)
  426. {
  427.    int j = s % 7;
  428.    off = (j < 5);
  429.    if ( ! off ) {
  430.       MoveTo (x, y);
  431.       LineTo (x, y);
  432.    }
  433. }
  434.  
  435.  
  436.  
  437. static void plotdotdash (int x, int y, int s)
  438. {
  439.    int j = s % 15;
  440.    off = (j < 4) || ((j > 5) && (j < 9));
  441.    if ( ! off) {
  442.       MoveTo (x, y);
  443.       LineTo (x, y);
  444.    }
  445. }
  446.  
  447.  
  448. static void LS_MOVETO (int x, int y)   /*Already Mac coordinates*/
  449. {
  450.    xpresent = x;
  451.    ypresent = y;
  452.    MoveTo (xpresent, ypresent);
  453. }
  454.  
  455.  
  456. static void LS_LINETO_difficult
  457.    (int xnew, int ynew,
  458.     voidfuncptr plot_with_line_style)
  459. {
  460.    register long_step, short_step, ax, di, bp, si, temp, x, y;
  461.  
  462.    long_step = 1;
  463.    short_step = 1;
  464.    bp = xnew - xpresent;
  465.    if (bp < 0)
  466.       {
  467.          long_step = -1;
  468.          bp = -bp;
  469.       };
  470.    ax = ynew - ypresent;
  471.    if (ax < 0)
  472.       {
  473.          short_step = -1;
  474.          ax = -ax;
  475.       };
  476.    x = xpresent;
  477.    y = ypresent;
  478.    if (ax <= bp)
  479.       {
  480.          di = bp>>1;
  481.          si = 0;
  482.          do {
  483.             plot_with_line_style (x, y, si);
  484.             x += long_step;
  485.             di += ax;
  486.             if (di >= bp)
  487.                {
  488.                   di -= bp;
  489.                   y += short_step;
  490.                }
  491.          }
  492.          while ((++si) <= bp);
  493.       }
  494.    else
  495.       {
  496.          temp = ax;
  497.          ax = bp;
  498.          bp = temp;
  499.          temp = short_step;
  500.          short_step = long_step;
  501.          long_step = temp;
  502.          di = (bp>>1);
  503.          si = 0;
  504.          do {
  505.             plot_with_line_style (x, y, si);
  506.             y += long_step;
  507.             di += ax;
  508.             if (di >= bp)
  509.                {
  510.                   di -= bp;
  511.                   x += short_step;
  512.                }
  513.          }
  514.          while ((++si) <= bp);
  515.       }
  516. };
  517.  
  518.  
  519. static void LS_LINETO (int xnew, int ynew)
  520. {
  521.    if (srgp__curActiveCanvasSpec.attributes.line_style == CONTINUOUS)
  522.       LineTo (xnew, ynew);
  523.    else {
  524.       if (xnew == xpresent)
  525.          PenSize (srgp__curActiveCanvasSpec.attributes.line_width, 1);
  526.       else if (ynew == ypresent)
  527.          PenSize (1, srgp__curActiveCanvasSpec.attributes.line_width);
  528.       else if (abs(ynew - ypresent) < abs(xnew - xpresent))
  529.          PenSize (1, srgp__curActiveCanvasSpec.attributes.line_width);
  530.       else
  531.          PenSize (srgp__curActiveCanvasSpec.attributes.line_width, 1);
  532.  
  533.       switch (srgp__curActiveCanvasSpec.attributes.line_style) {
  534.        case DASHED:
  535.          LS_LINETO_difficult (xnew, ynew, plotdash); break;
  536.        case DOTTED:
  537.          LS_LINETO_difficult (xnew, ynew, plotdot); break;
  538.        case DOT_DASHED:
  539.          LS_LINETO_difficult (xnew, ynew, plotdotdash); break;
  540.       }
  541.    }
  542.    xpresent = xnew;
  543.    ypresent = ynew;
  544. }
  545.  
  546. #endif
  547.  
  548. void
  549. SRGP_lineCoord (int x1, int y1, int x2, int y2)
  550. {
  551.    DEBUG_AIDS{
  552.       SRGP_trace (SRGP_logStream, "SRGP_lineCoord: %d,%d --> %d,%d\n", x1,y1,x2,y2);
  553.       srgp_check_system_state();
  554.       LeaveIfNonFatalErr();
  555.    }
  556.  
  557.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  558. #ifdef X11
  559.    XDrawLine
  560.       (srgpx__display,
  561.        srgp__curActiveCanvasSpec.drawable.xid,
  562.        srgp__curActiveCanvasSpec.gc_frame,
  563.        x1, FIXED(y1), x2, FIXED(y2));
  564. #endif
  565. #ifdef THINK_C
  566.    SET_PORT_FOR_FRAME_GENRE();
  567.    LS_MOVETO (x1,FIXED(y1));
  568.    LS_LINETO (x2,FIXED(y2));
  569. #endif
  570. #ifdef GRX
  571.    {
  572.         BUILD_GRX_DRAWTABLE(4,Line);
  573.         GRX_DRAW_FUNC(x1,FIXED(y1),x2,FIXED(y2),GRX_DRAW_ARG);
  574.    }
  575. #endif
  576.  
  577.    TURN_ON_RUBBER_ECHO_IF_ANY;
  578. }
  579.  
  580. void
  581. SRGP_line (point pt1, point pt2)
  582. {
  583.    DEBUG_AIDS{
  584.       SRGP_trace (SRGP_logStream, "SRGP_line: %d,%d --> %d,%d\n", ExplodePt(pt1), ExplodePt(pt2));
  585.    }
  586.  
  587.    PUSH_TRACE;
  588.    SRGP_lineCoord (pt1.x, pt1.y,  pt2.x, pt2.y);
  589.    POP_TRACE;
  590. }
  591.  
  592.  
  593.  
  594. /** RECTANGLES
  595. **/
  596.  
  597. void
  598. SRGP_rectangleCoord (int left_x, int bottom_y, int right_x, int top_y)
  599. {
  600.    DEBUG_AIDS{
  601.       SRGP_trace (SRGP_logStream, "SRGP_rectangleCoord: (%d,%d)->(%d,%d)\n",
  602.                   left_x, bottom_y, right_x, top_y);
  603.       srgp_check_system_state();
  604.       srgp_check_rectangle (left_x, bottom_y, right_x, top_y);
  605.       LeaveIfNonFatalErr();
  606.    }
  607.  
  608.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  609. #ifdef X11
  610.    XDrawRectangle
  611.       (srgpx__display,
  612.        srgp__curActiveCanvasSpec.drawable.xid,
  613.        srgp__curActiveCanvasSpec.gc_frame,
  614.        left_x, FIXED(top_y),
  615.        (right_x-left_x),
  616.        (top_y-bottom_y));
  617. #endif
  618. #ifdef THINK_C
  619.    SET_PORT_FOR_FRAME_GENRE();
  620.    r = FIXED_RECT(left_x, bottom_y, right_x, top_y);
  621.    if (srgp__curActiveCanvasSpec.attributes.line_style == CONTINUOUS)
  622.       FrameRect (&r);
  623.    else {
  624.       r.bottom -= srgp__curActiveCanvasSpec.attributes.line_width;
  625.       r.right -= srgp__curActiveCanvasSpec.attributes.line_width;
  626.       LS_MOVETO (r.left, r.bottom);
  627.       LS_LINETO (r.right, r.bottom);
  628.       LS_LINETO (r.right, r.top);
  629.       LS_LINETO (r.left, r.top);
  630.       LS_LINETO (r.left, r.bottom);
  631.    }
  632. #endif
  633. #ifdef GRX
  634.    {
  635.         BUILD_GRX_DRAWTABLE(4,Box);
  636.         GRX_DRAW_FUNC(left_x,FIXED(top_y),right_x,FIXED(bottom_y),GRX_DRAW_ARG);
  637.    }
  638. #endif
  639.    TURN_ON_RUBBER_ECHO_IF_ANY;
  640. }
  641.  
  642. void
  643. SRGP_rectangle (rectangle rect)
  644. {
  645.    DEBUG_AIDS{
  646.       SRGP_trace (SRGP_logStream, "SRGP_rectangle: (%d,%d)->(%d,%d)\n", ExplodeRect(rect));
  647.    }
  648.  
  649.    PUSH_TRACE;
  650.    SRGP_rectangleCoord
  651.       (rect.bottom_left.x, rect.bottom_left.y,
  652.        rect.top_right.x, rect.top_right.y);
  653.    POP_TRACE;
  654. }
  655.  
  656. void
  657. SRGP_rectanglePt (point bottom_left, point top_right)
  658. {
  659.    DEBUG_AIDS{
  660.       SRGP_trace (SRGP_logStream, "SRGP_rectanglePt: (%d,%d)->(%d,%d)\n",
  661.                   ExplodePt(bottom_left), ExplodePt(top_right));
  662.    }
  663.  
  664.    PUSH_TRACE;
  665.    SRGP_rectangleCoord
  666.       (bottom_left.x, bottom_left.y,
  667.        top_right.x, top_right.y);
  668.    POP_TRACE;
  669. }
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677. /** FRAMED POLYGONS
  678. **/
  679.  
  680. void
  681. SRGP_polyLine (int vertex_count, point *vertices)
  682. {
  683.    register int i;
  684.  
  685.    DEBUG_AIDS{
  686.       SRGP_trace (SRGP_logStream, "SRGP_polyLine  %d 0x%x\n", vertex_count, vertices);
  687.       srgp_check_system_state();
  688.       srgp_check_polyline_list_size(vertex_count);
  689.       LeaveIfNonFatalErr();
  690.    }
  691.  
  692.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  693. #ifdef X11
  694.    for (i=0; i < vertex_count; i++) {
  695.       Xformat_vertices[i].x = vertices[i].x;
  696.       Xformat_vertices[i].y = FIXED(vertices[i].y);
  697.    }
  698.    XDrawLines
  699.       (srgpx__display,
  700.        srgp__curActiveCanvasSpec.drawable.xid,
  701.        srgp__curActiveCanvasSpec.gc_frame,
  702.        Xformat_vertices, vertex_count, CoordModeOrigin);
  703. #endif
  704. #ifdef THINK_C
  705.    SET_PORT_FOR_FRAME_GENRE();
  706.    LS_MOVETO (vertices[0].x, FIXED(vertices[0].y));
  707.    for (i=1; i < vertex_count; i++)
  708.       LS_LINETO (vertices[i].x, FIXED(vertices[i].y));
  709. #endif
  710. #ifdef GRX
  711.    {
  712.         int temp[GR_MAX_POLY_VERTICES][2];
  713.         BUILD_GRX_DRAWTABLE(POLY,PolyLine);
  714.  
  715.         for(i=0; i < vertex_count; i++) {
  716.             temp[i][0] = vertices[i].x;
  717.             temp[i][1] = FIXED(vertices[i].y);
  718.         }
  719.         GRX_DRAW_FUNC(vertex_count,temp,GRX_DRAW_ARG);
  720.    }
  721. #endif
  722.  
  723.    TURN_ON_RUBBER_ECHO_IF_ANY;
  724. }
  725.  
  726.  
  727. void
  728. SRGP_polyLineCoord (int vertex_count, int *x_coords, int *y_coords)
  729. {
  730.    register int i;
  731.  
  732.    DEBUG_AIDS{
  733.       SRGP_trace (SRGP_logStream, "SRGP_polyLineCoord  %d 0x%x,0x%x\n",
  734.                   vertex_count, x_coords, y_coords);
  735.       srgp_check_system_state();
  736.       srgp_check_polyline_list_size(vertex_count);
  737.       LeaveIfNonFatalErr();
  738.    }
  739.  
  740.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  741. #ifdef X11
  742.    for (i=0; i < vertex_count; i++) {
  743.       Xformat_vertices[i].x = x_coords[i];
  744.       Xformat_vertices[i].y = FIXED(y_coords[i]);
  745.    }
  746.    XDrawLines
  747.       (srgpx__display,
  748.        srgp__curActiveCanvasSpec.drawable.xid,
  749.        srgp__curActiveCanvasSpec.gc_frame,
  750.        Xformat_vertices, vertex_count, CoordModeOrigin);
  751. #endif
  752. #ifdef THINK_C
  753.    SET_PORT_FOR_FRAME_GENRE();
  754.    LS_MOVETO (x_coords[0], FIXED(y_coords[0]));
  755.    for (i=1; i < vertex_count; i++)
  756.       LS_LINETO (x_coords[i], FIXED(y_coords[i]));
  757. #endif
  758. #ifdef GRX
  759.    {
  760.         int temp[GR_MAX_POLY_VERTICES][2];
  761.         BUILD_GRX_DRAWTABLE(POLY,PolyLine);
  762.  
  763.         for(i=0; i < vertex_count; i++) {
  764.             temp[i][0] = x_coords[i];
  765.             temp[i][1] = FIXED(y_coords[i]);
  766.         }
  767.         GRX_DRAW_FUNC(vertex_count,temp,GRX_DRAW_ARG);
  768.    }
  769. #endif
  770.    TURN_ON_RUBBER_ECHO_IF_ANY;
  771. }
  772.  
  773.  
  774. void
  775. SRGP_polygon (int vertex_count, point *vertices)
  776. {
  777.    DEBUG_AIDS{
  778.       SRGP_trace (SRGP_logStream, "SRGP_polygon  %d 0x%x\n",
  779.                   vertex_count, vertices);
  780.       srgp_check_system_state();
  781.       srgp_check_polygon_list_size(vertex_count);
  782.       LeaveIfNonFatalErr();
  783.    }
  784.  
  785.    PUSH_TRACE;
  786.    SRGP_polyLine (vertex_count, vertices);
  787.    /* draw the line between the first vertex and the last vertex */
  788.    SRGP_line (vertices[0], vertices[vertex_count-1]);
  789.    POP_TRACE;
  790. }
  791.  
  792.  
  793. void
  794. SRGP_polygonCoord (int vertex_count, int *x_coords, int *y_coords)
  795. {
  796.    DEBUG_AIDS{
  797.       SRGP_trace (SRGP_logStream, "SRGP_polygonCoord  %d 0x%x,0x%x\n",
  798.                   vertex_count, x_coords, y_coords);
  799.       srgp_check_system_state();
  800.       srgp_check_polygon_list_size(vertex_count);
  801.       LeaveIfNonFatalErr();
  802.    }
  803.  
  804.    PUSH_TRACE;
  805.    SRGP_polyLineCoord (vertex_count, x_coords, y_coords);
  806.    /* draw the line between the first vertex and the last vertex */
  807.    SRGP_lineCoord
  808.       (x_coords[0], y_coords[0],
  809.        x_coords[vertex_count-1], y_coords[vertex_count-1]);
  810.    POP_TRACE;
  811. }
  812.  
  813.  
  814.  
  815. /** FILLED RECTANGLES AND POLYGONS
  816. **/
  817.  
  818. void
  819. SRGP_fillRectangleCoord (int left_x, int bottom_y, int right_x, int top_y)
  820. {
  821.    DEBUG_AIDS{
  822.       SRGP_trace (SRGP_logStream, "SRGP_fillRectangleCoord (%d,%d)->(%d,%d)\n",
  823.                   left_x, bottom_y, right_x, top_y);
  824.       srgp_check_system_state();
  825.       srgp_check_rectangle(left_x, bottom_y, right_x, top_y);
  826.       LeaveIfNonFatalErr();
  827.    }
  828.  
  829.  
  830.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  831. #ifdef X11
  832.    XFillRectangle
  833.       (srgpx__display,
  834.        srgp__curActiveCanvasSpec.drawable.xid,
  835.        srgp__curActiveCanvasSpec.gc_fill,
  836.        left_x, FIXED(top_y),
  837.        (right_x-left_x+1), (top_y-bottom_y+1));
  838. #endif
  839. #ifdef THINK_C
  840.    SET_PORT_FOR_FILL_GENRE();
  841.    r = FIXED_RECT(left_x, bottom_y, right_x, top_y);
  842.    if (srgp__curActiveCanvasSpec.attributes.fill_style == PIXMAP_PATTERN)
  843.       FillCRect
  844.          (&r,
  845.           srgp__pixmapPatternTable
  846.              [srgp__curActiveCanvasSpec.attributes.fill_pixmap_pattern_id]);
  847.    else
  848.    PaintRect (&r);
  849. #endif
  850. #ifdef GRX
  851.    {
  852.         BUILD_GRX_FILLTABLE(4,Box);
  853.         GRX_FILL_FUNC(left_x,FIXED(top_y),right_x,FIXED(bottom_y),GRX_FILL_ARG);
  854.    }
  855. #endif
  856.    TURN_ON_RUBBER_ECHO_IF_ANY;
  857. }
  858.  
  859. void
  860. SRGP_fillRectangle (rectangle rect)
  861. {
  862.    DEBUG_AIDS{
  863.       SRGP_trace (SRGP_logStream, "SRGP_fillRectangle (%d,%d)->(%d,%d)\n",
  864.                   ExplodeRect(rect));
  865.    }
  866.  
  867.    PUSH_TRACE;
  868.    SRGP_fillRectangleCoord
  869.       (rect.bottom_left.x, rect.bottom_left.y,
  870.        rect.top_right.x, rect.top_right.y);
  871.    POP_TRACE;
  872. }
  873.  
  874. void
  875. SRGP_fillRectanglePt (point bottom_left, point top_right)
  876. {
  877.    DEBUG_AIDS{
  878.       SRGP_trace (SRGP_logStream, "SRGP_fillRectanglePt (%d,%d)->(%d,%d)\n",
  879.                   ExplodePt(bottom_left), ExplodePt(top_right));
  880.    }
  881.  
  882.    PUSH_TRACE;
  883.    SRGP_fillRectangleCoord
  884.       (bottom_left.x, bottom_left.y,
  885.        top_right.x, top_right.y);
  886.    POP_TRACE;
  887. }
  888.  
  889.  
  890. void
  891. SRGP_fillPolygon (int vertex_count, point *vertices)
  892. {
  893.    register int i;
  894. #ifdef THINK_C
  895.    PolyHandle p;
  896. #endif
  897.  
  898.    DEBUG_AIDS{
  899.       SRGP_trace (SRGP_logStream, "SRGP_fillPolygon:  %d  0x%x\n",
  900.                   vertex_count, vertices);
  901.       srgp_check_system_state();
  902.       srgp_check_polygon_list_size(vertex_count);
  903.       LeaveIfNonFatalErr();
  904.    }
  905.  
  906.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  907.  
  908. #ifdef X11
  909.    for (i=0; i < vertex_count; i++) {
  910.       Xformat_vertices[i].x = vertices[i].x;
  911.       Xformat_vertices[i].y = FIXED(vertices[i].y);
  912.    }
  913.    XFillPolygon
  914.       (srgpx__display,
  915.        srgp__curActiveCanvasSpec.drawable.xid,
  916.        srgp__curActiveCanvasSpec.gc_fill,
  917.        Xformat_vertices, vertex_count, Complex, CoordModeOrigin);
  918. #endif
  919.  
  920. #ifdef THINK_C
  921.    p = OpenPoly();
  922.    MoveTo (vertices[0].x, FIXED(vertices[0].y));
  923.    for (i=1; i < vertex_count; i++)
  924.       LineTo (vertices[i].x, FIXED(vertices[i].y));
  925.    ClosePoly ();
  926.    if (srgp__curActiveCanvasSpec.attributes.fill_style == PIXMAP_PATTERN)
  927.       FillCPoly
  928.          (p,
  929.           srgp__pixmapPatternTable
  930.              [srgp__curActiveCanvasSpec.attributes.fill_pixmap_pattern_id]);
  931.    else {
  932.       SET_PORT_FOR_FILL_GENRE();
  933.       PaintPoly (p);
  934.    }
  935.    KillPoly (p);
  936. #endif
  937. #ifdef GRX
  938.    {
  939.         int temp[GR_MAX_POLY_VERTICES][2];
  940.         BUILD_GRX_FILLTABLE(POLY,Polygon);
  941.  
  942.         for(i=0; i < vertex_count; i++) {
  943.             temp[i][0] = vertices[i].x;
  944.             temp[i][1] = FIXED(vertices[i].y);
  945.         }
  946.         GRX_FILL_FUNC(vertex_count,temp,GRX_FILL_ARG);
  947.    }
  948. #endif
  949.  
  950.    TURN_ON_RUBBER_ECHO_IF_ANY;
  951. }
  952.  
  953.  
  954. void
  955. SRGP_fillPolygonCoord (int vertex_count, int *x_coords, int *y_coords)
  956. {
  957.    register int i;
  958. #ifdef THINK_C
  959.    PolyHandle p;
  960. #endif
  961.  
  962.    DEBUG_AIDS{
  963.       SRGP_trace (SRGP_logStream, "SRGP_fillPolygonCoord:  %d  0x%x,0x%x\n",
  964.                   vertex_count, x_coords, y_coords);
  965.       srgp_check_system_state();
  966.       srgp_check_polygon_list_size(vertex_count);
  967.       LeaveIfNonFatalErr();
  968.    }
  969.  
  970.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  971.  
  972. #ifdef X11
  973.    for (i=0; i < vertex_count; i++) {
  974.       Xformat_vertices[i].x = x_coords[i];
  975.       Xformat_vertices[i].y = FIXED(y_coords[i]);
  976.    }
  977.    XFillPolygon
  978.       (srgpx__display,
  979.        srgp__curActiveCanvasSpec.drawable.xid,
  980.        srgp__curActiveCanvasSpec.gc_fill,
  981.        Xformat_vertices, vertex_count, Complex, CoordModeOrigin);
  982. #endif
  983.  
  984. #ifdef THINK_C
  985.    p = OpenPoly();
  986.    MoveTo (x_coords[0], FIXED(y_coords[0]));
  987.    for (i=1; i < vertex_count; i++)
  988.       LineTo (x_coords[i], FIXED(y_coords[i]));
  989.    ClosePoly ();
  990.    if (srgp__curActiveCanvasSpec.attributes.fill_style == PIXMAP_PATTERN)
  991.       FillCPoly
  992.          (p,
  993.           srgp__pixmapPatternTable
  994.              [srgp__curActiveCanvasSpec.attributes.fill_pixmap_pattern_id]);
  995.    else {
  996.       SET_PORT_FOR_FILL_GENRE();
  997.       PaintPoly (p);
  998.    }
  999.    KillPoly (p);
  1000. #endif
  1001. #ifdef GRX
  1002.    {
  1003.         int temp[GR_MAX_POLY_VERTICES][2];
  1004.         BUILD_GRX_FILLTABLE(POLY,Polygon);
  1005.  
  1006.         for(i=0; i < vertex_count; i++) {
  1007.             temp[i][0] = x_coords[i];
  1008.             temp[i][1] = FIXED(y_coords[i]);
  1009.         }
  1010.         GRX_DRAW_FUNC(vertex_count,temp,GRX_DRAW_ARG);
  1011.    }
  1012. #endif
  1013.    TURN_ON_RUBBER_ECHO_IF_ANY;
  1014. }
  1015.  
  1016.  
  1017.  
  1018. /** ELLIPSES
  1019. **/
  1020.  
  1021. #ifdef X11
  1022. static int xangle1, xangle2;
  1023.  
  1024. ComputeXangles (double start, double end)
  1025. {
  1026.    if (start <= end) {
  1027.       xangle1 = (int)(start*64);
  1028.       xangle2 = (int)((end-start)*64);
  1029.    }
  1030.    else {
  1031.       xangle1 = (int) (end*64);
  1032.       xangle2 = (int) ((start-360.0-end)*64);
  1033.    }
  1034. }
  1035. #endif
  1036.  
  1037. #ifdef GRX
  1038. # define GRX_ANGLE(x)   ((int)((x) * 10.0))
  1039. #endif
  1040.  
  1041. void
  1042. SRGP_ellipseArc (rectangle bounding_rect, double start, double end)
  1043. {
  1044.  
  1045.  
  1046.    DEBUG_AIDS{
  1047.       SRGP_trace (SRGP_logStream, "SRGP_ellipse:  (%d,%d)->(%d,%d)\n",
  1048.                   ExplodeRect(bounding_rect));
  1049.       srgp_check_system_state();
  1050.       srgp_check_rectangle
  1051.          (bounding_rect.bottom_left.x, bounding_rect.bottom_left.y,
  1052.           bounding_rect.top_right.x, bounding_rect.top_right.y);
  1053.       LeaveIfNonFatalErr();
  1054.    }
  1055.  
  1056.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  1057. #ifdef X11
  1058.    ComputeXangles (start, end);
  1059.    XDrawArc
  1060.       (srgpx__display,
  1061.        srgp__curActiveCanvasSpec.drawable.xid,
  1062.        srgp__curActiveCanvasSpec.gc_frame,
  1063.        bounding_rect.bottom_left.x, FIXED(bounding_rect.top_right.y),
  1064.        (bounding_rect.top_right.x - bounding_rect.bottom_left.x),
  1065.        (bounding_rect.top_right.y - bounding_rect.bottom_left.y),
  1066.        xangle1, xangle2);
  1067. #endif
  1068. #ifdef THINK_C
  1069.    SetRect (&r, bounding_rect.bottom_left.x, FIXED(bounding_rect.top_right.y),
  1070.                 bounding_rect.top_right.x, FIXED(bounding_rect.bottom_left.y));
  1071.    SET_PORT_FOR_FRAME_GENRE();
  1072.    FrameArc (&r, (int)(90 - start), (int)(-(end+((start>end)?360:0) - start)));
  1073. #endif
  1074. #ifdef GRX
  1075.    {
  1076.         BUILD_GRX_DRAWTABLE(6,EllipseArc);
  1077.         GRX_DRAW_FUNC(
  1078.             ((bounding_rect.top_right.x + bounding_rect.bottom_left.x) >> 1),
  1079.             FIXED((bounding_rect.top_right.y + bounding_rect.bottom_left.y) >> 1),
  1080.             ((bounding_rect.top_right.x - bounding_rect.bottom_left.x) >> 1),
  1081.             ((bounding_rect.top_right.y - bounding_rect.bottom_left.y) >> 1),
  1082.             GRX_ANGLE(start),
  1083.             GRX_ANGLE(end),
  1084.             GRX_DRAW_ARG
  1085.         );
  1086.    }
  1087. #endif
  1088.    TURN_ON_RUBBER_ECHO_IF_ANY;
  1089. }
  1090.  
  1091.  
  1092. void
  1093. SRGP_ellipse (rectangle bounding_rect)
  1094. {
  1095.    DEBUG_AIDS{
  1096.       SRGP_trace (SRGP_logStream, "SRGP_ellipse:  (%d,%d)->(%d,%d)\n",
  1097.                   ExplodeRect(bounding_rect));
  1098.       srgp_check_system_state();
  1099.       srgp_check_rectangle
  1100.          (bounding_rect.bottom_left.x, bounding_rect.bottom_left.y,
  1101.           bounding_rect.top_right.x, bounding_rect.top_right.y);
  1102.       LeaveIfNonFatalErr();
  1103.    }
  1104.  
  1105.    PUSH_TRACE;
  1106. #ifndef GRX
  1107.    SRGP_ellipseArc (bounding_rect, 0.0, 360.0);
  1108. #else
  1109.    {
  1110.         BUILD_GRX_DRAWTABLE(4,Ellipse);
  1111.         GRX_DRAW_FUNC(
  1112.             ((bounding_rect.top_right.x + bounding_rect.bottom_left.x) >> 1),
  1113.             FIXED((bounding_rect.top_right.y + bounding_rect.bottom_left.y) >> 1),
  1114.             ((bounding_rect.top_right.x - bounding_rect.bottom_left.x) >> 1),
  1115.             ((bounding_rect.top_right.y - bounding_rect.bottom_left.y) >> 1),
  1116.             GRX_DRAW_ARG
  1117.         );
  1118.    }
  1119. #endif
  1120.    POP_TRACE;
  1121. }
  1122.  
  1123.  
  1124.  
  1125.  
  1126. void
  1127. SRGP_fillEllipseArc (rectangle bounding_rect, double start, double end)
  1128. {
  1129.    DEBUG_AIDS{
  1130.       SRGP_trace (SRGP_logStream, "SRGP_fillEllipseArc:  (%d,%d)->(%d,%d)\n",
  1131.                   ExplodeRect(bounding_rect));
  1132.       srgp_check_system_state();
  1133.       srgp_check_rectangle
  1134.          (bounding_rect.bottom_left.x, bounding_rect.bottom_left.y,
  1135.           bounding_rect.top_right.x, bounding_rect.top_right.y);
  1136.       LeaveIfNonFatalErr();
  1137.    }
  1138.  
  1139.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  1140. #ifdef X11
  1141.    ComputeXangles (start, end);
  1142.    XFillArc
  1143.       (srgpx__display,
  1144.        srgp__curActiveCanvasSpec.drawable.xid,
  1145.        srgp__curActiveCanvasSpec.gc_fill,
  1146.        bounding_rect.bottom_left.x, FIXED(bounding_rect.top_right.y),
  1147.        (bounding_rect.top_right.x - bounding_rect.bottom_left.x),
  1148.        (bounding_rect.top_right.y - bounding_rect.bottom_left.y),
  1149.        xangle1, xangle2);
  1150. #endif
  1151.  
  1152. #ifdef THINK_C
  1153.    SetRect (&r, bounding_rect.bottom_left.x, FIXED(bounding_rect.top_right.y),
  1154.                 bounding_rect.top_right.x, FIXED(bounding_rect.bottom_left.y));
  1155.    if (srgp__curActiveCanvasSpec.attributes.fill_style == PIXMAP_PATTERN)
  1156.       FillCArc (&r, (int)(90 - start), (int)(-(end+((start>end)?360:0) - start)),
  1157.                 srgp__pixmapPatternTable
  1158.                    [srgp__curActiveCanvasSpec.attributes.fill_pixmap_pattern_id]);
  1159.    else {
  1160.       SET_PORT_FOR_FILL_GENRE();
  1161.       PaintArc (&r, (int)(90 - start), (int)(-(end+((start>end)?360:0) - start)));
  1162.    }
  1163. #endif
  1164. #ifdef GRX
  1165.    {
  1166.         BUILD_GRX_FILLTABLE(6,EllipseArc);
  1167.         GRX_FILL_FUNC(
  1168.             ((bounding_rect.top_right.x + bounding_rect.bottom_left.x) >> 1),
  1169.             FIXED((bounding_rect.top_right.y + bounding_rect.bottom_left.y) >> 1),
  1170.             ((bounding_rect.top_right.x - bounding_rect.bottom_left.x) >> 1),
  1171.             ((bounding_rect.top_right.y - bounding_rect.bottom_left.y) >> 1),
  1172.             GRX_ANGLE(start),
  1173.             GRX_ANGLE(end),
  1174.             GRX_FILL_ARG
  1175.         );
  1176.    }
  1177. #endif
  1178.    TURN_ON_RUBBER_ECHO_IF_ANY;
  1179. }
  1180.  
  1181.  
  1182.  
  1183. void
  1184. SRGP_fillEllipse (rectangle bounding_rect)
  1185. {
  1186.    DEBUG_AIDS{
  1187.       SRGP_trace (SRGP_logStream, "SRGP_fillEllipse:  (%d,%d)->(%d,%d)\n",
  1188.                   ExplodeRect(bounding_rect));
  1189.       srgp_check_system_state();
  1190.       srgp_check_rectangle
  1191.          (bounding_rect.bottom_left.x, bounding_rect.bottom_left.y,
  1192.           bounding_rect.top_right.x, bounding_rect.top_right.y);
  1193.       LeaveIfNonFatalErr();
  1194.    }
  1195.  
  1196.    PUSH_TRACE;
  1197. #ifndef GRX
  1198.    SRGP_fillEllipseArc (bounding_rect, 0.0, 360.0);
  1199. #else
  1200.    {
  1201.         BUILD_GRX_FILLTABLE(4,Ellipse);
  1202.         GRX_FILL_FUNC(
  1203.             ((bounding_rect.top_right.x + bounding_rect.bottom_left.x) >> 1),
  1204.             FIXED((bounding_rect.top_right.y + bounding_rect.bottom_left.y) >> 1),
  1205.             ((bounding_rect.top_right.x - bounding_rect.bottom_left.x) >> 1),
  1206.             ((bounding_rect.top_right.y - bounding_rect.bottom_left.y) >> 1),
  1207.             GRX_FILL_ARG
  1208.         );
  1209.    }
  1210. #endif
  1211.    POP_TRACE;
  1212. }
  1213.  
  1214.  
  1215.  
  1216. /** TEXT
  1217. X11 implementation notes:
  1218.    Unfortunately, we don't keep a GC around just for text.
  1219.    Neither the frame nor the fill GC are necessarily correct for text;
  1220.    text is always drawn in SOLID style.
  1221.  
  1222.    Basically, if we find that the frame GC currently has a non-solid X-fill-style,
  1223.    we temporarily change the frame GC's X-fill-style to SOLID and then restore.
  1224.  
  1225.    This could be woefully inefficient if the application is indeed using
  1226.    a non-solid pen-style!
  1227. **/
  1228.  
  1229. #ifdef GRX
  1230. # include <string.h>
  1231. #endif
  1232.  
  1233. void
  1234. SRGP_text (point origin, char *str)
  1235. {
  1236. #ifdef X11
  1237.    boolean restoration_needed = FALSE;
  1238. #endif
  1239.  
  1240.    DEBUG_AIDS{
  1241.       SRGP_trace (SRGP_logStream, "SRGP_text:  %d,%d  %s\n",
  1242.                   origin.x, origin.y, str);
  1243.       srgp_check_system_state();
  1244.       LeaveIfNonFatalErr();
  1245.    }
  1246.  
  1247.    TURN_OFF_RUBBER_ECHO_IF_ANY;
  1248.  
  1249. #ifdef X11
  1250.    if (srgp__curActiveCanvasSpec.attributes.pen_style != SOLID) {
  1251.       restoration_needed = TRUE;
  1252.       XSetFillStyle (srgpx__display,
  1253.                      srgp__curActiveCanvasSpec.gc_frame, SOLID);
  1254.    }
  1255.  
  1256.    XDrawString
  1257.       (srgpx__display,
  1258.        srgp__curActiveCanvasSpec.drawable.xid,
  1259.        srgp__curActiveCanvasSpec.gc_frame,
  1260.        origin.x, FIXED(origin.y), str, strlen(str));
  1261.  
  1262.    if (restoration_needed)
  1263.       XSetFillStyle (srgpx__display,
  1264.                      srgp__curActiveCanvasSpec.gc_frame,
  1265.                      srgp__curActiveCanvasSpec.attributes.pen_style);
  1266. #endif
  1267.  
  1268. #ifdef THINK_C
  1269.    PenPat(black);
  1270.    CtoPstr(str);
  1271.    MoveTo (origin.x, FIXED(origin.y));
  1272.    DrawString (str);
  1273.    PtoCstr(str);
  1274. #endif
  1275.  
  1276. #ifdef GRX
  1277.    GrDrawString(str,strlen(str),
  1278.         origin.x,FIXED(origin.y),
  1279.         &srgp__curActiveCanvasSpec.grx_textopt
  1280.    );
  1281. #endif
  1282.  
  1283.    TURN_ON_RUBBER_ECHO_IF_ANY;
  1284. }
  1285.  
  1286.